package us.mooresr.geartrack.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.geartrack.shared.model.Item;
import com.google.gwt.event.shared.HasHandlers;

public class ItemChangedEvent extends
		GwtEvent<ItemChangedEvent.ItemChangedHandler> {

	public static Type<ItemChangedHandler> TYPE = new Type<ItemChangedHandler>();
	private Item item;

	public interface ItemChangedHandler extends EventHandler {
		void onItemChanged(ItemChangedEvent event);
	}

	public ItemChangedEvent(Item item) {
		this.item = item;
	}

	public Item getItem() {
		return item;
	}

	@Override
	protected void dispatch(ItemChangedHandler handler) {
		handler.onItemChanged(this);
	}

	@Override
	public Type<ItemChangedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<ItemChangedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Item item) {
		source.fireEvent(new ItemChangedEvent(item));
	}
}
